<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of verification_helper
 *
 * @author Administrator
 */
class Verification{
    /*
     * 判断一个ip是否合法
     * @param string ip 需要判断的ip
     * @param bool ip6 ip是否是ip6
     * return bool
     */
    static public function ip($ip = 0,$ip6 = false)
    {
        if($ip6)
        {
                    return filter_var($ip, FILTER_VALIDATE_IP,FILTER_FLAG_IPV6);
        }
        else
        {
                    return filter_var($ip, FILTER_VALIDATE_IP);
        }
    }
    
    /*
     * 判断端口是否合法
     * @param int port
     * return bool
     */
    public function port($port)
    {
        if(is_numeric($port)  && $port > 0 && $port < 65536)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}